#!/usr/bin/env python
import traceback
import platform
from player_submission import OpenMoveEvalFn, CustomEvalFn, CustomPlayer
from isolation import Board, game_as_text
from test_players import RandomPlayer, HumanPlayer
if platform.system() != 'Windows':
   import resource
from time import time, sleep

def main():

    """Example test you can run
    than random."""
    print ""
    try:
        r = RandomPlayer()
        h = RandomPlayer()
        #h = CustomPlayer()
        game = Board(r, h, 3, 2)
        game.__board_state__ = [
            ["Q1",  "X", " ",],
            [ " ", "Q2", " ",],
        ]
        output_b = game.copy()
        winner, move_history, termination = game.play_isolation(time_limit=1000, print_moves=True)
        print "\n",winner," has won. Reason: ", termination
    # Uncomment to see game
    # print game_as_text(winner, move_history, termination, output_b)
    except NotImplementedError:
        print 'CustomPlayer Test: Not Implemented'
    except:
        print 'CustomPlayer Test: ERROR OCCURRED'
        print traceback.format_exc()

if __name__ == "__main__":
    main()
